package com.shop2cn.iapi.sqrefund.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.sqrefund.parameter.DeleteRefundAddressReq;
import com.shop2cn.iapi.sqrefund.service.DeleteRefundAddressCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P3;
import com.ymttest.database.model.sqrefund.MchRefundAddress;
import com.ymttest.database.sqlwapper.sqrefund.MchRefundAddressWrapper;

/**
 * 发货 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_DeleteRefundAddress {

	private static DeleteRefundAddressReq deleteRefundAddressReq;
	private static DeleteRefundAddressCall deleteRefundAddressCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("删除退货地址");
	}

	@Before
	public void caseUp() {

		deleteRefundAddressReq = new DeleteRefundAddressReq();
		deleteRefundAddressCall = new DeleteRefundAddressCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(deleteRefundAddressCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_DeleteRefundAddress_001() {
		Logger.start(false, "删除退货地址成功");
		try {
			
			deleteRefundAddressReq.setId(12L);
			deleteRefundAddressReq.setMerchantId(28723539L);
			deleteRefundAddressReq.setUserId(2151124L);
			deleteRefundAddressReq.setUsername("username");

			deleteRefundAddressCall.setData(deleteRefundAddressReq);
			deleteRefundAddressCall.callService();
			
			MchRefundAddressWrapper mchRefundAddressWrapper = new MchRefundAddressWrapper();
			
			MchRefundAddress mchRefundAddress = mchRefundAddressWrapper.selectByPrimaryKey(13L);
			
			Logger.verifyEquals(true, mchRefundAddress.getIs_deleted(),
					"Is_deleted");
					
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_DeleteRefundAddress_002() {
		Logger.start(false, "传入错误的merchantId，删除退货地址失败");
		try {
			
			deleteRefundAddressReq.setId(13L);
			deleteRefundAddressReq.setMerchantId(81224215119473L);
			deleteRefundAddressReq.setUserId(2151124L);
			deleteRefundAddressReq.setUsername("username");

			deleteRefundAddressCall.setData(deleteRefundAddressReq);
			deleteRefundAddressCall.callService();
			
			MchRefundAddressWrapper mchRefundAddressWrapper = new MchRefundAddressWrapper();
			
			MchRefundAddress mchRefundAddress = mchRefundAddressWrapper.selectByPrimaryKey(13L);
			
			Logger.verifyEquals(false, mchRefundAddress.getIs_deleted(),
					"Is_deleted");
					
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
